/** @jsxImportSource @emotion/react */
import * as React from "react";
import {
    Text, LineColumn, InputLine, SuffixInput, Table, TableBody, TableRow, CCell, TableHead,
} from "customize-easy-ui-component";
import {
    InspectRecordLayout, InternalItemProps, RepLink, SelectHookfork, useItemInputControl,
} from "../../common/base";
import {useMeasureInpFilter} from "../../common/hooks";
import {floatInterception, } from "../../../common/tool";

export const tail底坑= <Text css={{"@media print": {fontSize: '0.75rem'}}}>
    注：本表所列项目无测量时，相关数据可不填写，但结果判定应填写，对不适用项填“/”。
</Text>;

const item底坑 = ['坑间1', '坑间2', '坑间3',  '底距4', '底距5', '底距6', '底距7'];
const itemA底坑 = ['坑高差H', '坑间r',  '底距4r', '底距5r', '底距6r', '底距7r'];
export const itemn底坑 =item底坑.concat(itemA底坑);
export const Pitspace =
    React.forwardRef(({children, show, alone = true, refWidth, label}: InternalItemProps, ref
    ) => {
        const [getInpFilter] = useMeasureInpFilter(item底坑, itemA底坑,);
        const {inp, setInp} = useItemInputControl({ref});
        return (
            <InspectRecordLayout inp={inp} setInp={setInp} getInpFilter={getInpFilter} show={show}
                                 alone={alone} label={label!}>
                {label}。 单位：m<br/>
                项目编号 A1.2.2.12.1; 轿厢完全压缩缓冲器时，层门地坎与轿厢地坎的高差值（H）：
                <InputLine label='轿厢完全压缩缓冲器时，层门地坎与轿厢地坎的高差值（H）'>
                    <SuffixInput  value={inp?.['坑高差H'] || ''} onSave={txt=> setInp({...inp,['坑高差H']: txt || undefined })}>m</SuffixInput>
                </InputLine>
                <hr/>
                项目 A1,A2,A3 检验要求: 底坑中有一个不小于 0.50m ×0.60m × 1.00m 的空间(任一平面朝下均可)；
                <LineColumn column={6}>
                    <InputLine label='轿厢在下端站平层位置时，所测量的底坑空间值A1'>
                        <SuffixInput  value={inp?.坑间1o || ''} onSave={txt=> setInp({...inp,坑间1o: txt || undefined })}>m</SuffixInput>
                    </InputLine>
                    <Text>轿厢完全压缩缓冲器时，底坑空间计算结果值:
                        (A1-H)= {floatInterception(inp?.['坑间1o'] - inp?.['坑高差H'], 2, )}</Text>
                    <InputLine label='底坑空间值A2'>
                        <SuffixInput  value={inp?.坑间2o || ''} onSave={txt=> setInp({...inp,坑间2o: txt || undefined })}>m</SuffixInput>
                    </InputLine>
                    <Text>轿厢完全压缩缓冲器时，底坑空间计算结果值:
                        (A2)= {floatInterception(inp?.['坑间2o'], 2, )}</Text>
                    <InputLine label='底坑空间值A3'>
                        <SuffixInput  value={inp?.坑间3o || ''} onSave={txt=> setInp({...inp,坑间3o: txt || undefined })}>m</SuffixInput>
                    </InputLine>
                    <Text>轿厢完全压缩缓冲器时，底坑空间计算结果值:
                        (A3)= {floatInterception(inp?.['坑间3o'], 2, )}</Text>
                    <InputLine label={`A1, A2, A3-判定结论`}>
                        <SelectHookfork value={inp?.坑间r || ''}
                                        onChange={e => setInp({...inp, 坑间r: e.currentTarget.value || undefined})}/>
                    </InputLine>
                </LineColumn>
                <hr/>
                项目 垂直距离A4 检验要求：底坑底面与轿厢最低部件的自由垂直距离不小于0.50m；
                <LineColumn column={6}>
                    <InputLine label='轿厢在下端站平层位置时，所测量的底坑空间值A4'>
                        <SuffixInput  value={inp?.底距4o || ''} onSave={txt=> setInp({...inp,底距4o: txt || undefined })}>m</SuffixInput>
                    </InputLine>
                    <Text>轿厢完全压缩缓冲器时，底坑空间计算结果值
                        (A4-H)= {floatInterception(inp?.['底距4o'] - inp?.['坑高差H'], 2)}</Text>
                    <InputLine label={`垂直距离A4-判定结论`}>
                        <SelectHookfork value={inp?.底距4r || ''}
                                        onChange={e => setInp({...inp, 底距4r: e.currentTarget.value || undefined})}/>
                    </InputLine>
                </LineColumn>
                项目 垂直距离A5 检验要求：当垂直滑动门的部件、护脚板、夹紧装置钳块或者棘爪装置和相邻井道壁之间，轿厢最低部件和导轨之间的水平距离在 0.15m 之内时，此垂直距离允许减少到 0.10m；
                <LineColumn column={6}>
                    <InputLine label='轿厢在下端站平层位置时，所测量的底坑空间值A5'>
                        <SuffixInput  value={inp?.底距5o || ''} onSave={txt=> setInp({...inp,底距5o: txt || undefined })}>m</SuffixInput>
                    </InputLine>
                    <Text>轿厢完全压缩缓冲器时，底坑空间计算结果值
                        (A5-H)= {floatInterception(inp?.['底距5o'] - inp?.['坑高差H'], 2)}</Text>
                    <InputLine label={`垂直距离A5-判定结论`}>
                        <SelectHookfork value={inp?.底距5r || ''}
                                        onChange={e => setInp({...inp, 底距5r: e.currentTarget.value || undefined})}/>
                    </InputLine>
                </LineColumn>
                项目 垂直距离A6 检验要求：当轿厢最低部件和导轨之间的水平距离大于 0.15m 但不大于 0.50时，此垂直距离可按线性关系增加至0.50m；
                <LineColumn column={6}>
                    <InputLine label='轿厢在下端站平层位置时，所测量的底坑空间值A6'>
                        <SuffixInput  value={inp?.底距6o || ''} onSave={txt=> setInp({...inp,底距6o: txt || undefined })}>m</SuffixInput>
                    </InputLine>
                    <Text>轿厢完全压缩缓冲器时，底坑空间计算结果值
                        (A6-H)= {floatInterception(inp?.['底距6o'] - inp?.['坑高差H'], 2)}</Text>
                    <InputLine label={`垂直距离A6-判定结论`}>
                        <SelectHookfork value={inp?.底距6r || ''}
                                        onChange={e => setInp({...inp, 底距6r: e.currentTarget.value || undefined})}/>
                    </InputLine>
                </LineColumn>
                <hr/>
                项目 垂直距离A7 检验要求：底坑中固定的最高部件和轿厢最低部件(垂直滑动门的部件、护脚板、夹紧装置钳块或者棘爪装置除外)之间的自由垂直距离不小于0.30m。
                <LineColumn column={6}>
                    <InputLine label='轿厢在下端站平层位置时，所测量的底坑空间值A7'>
                        <SuffixInput  value={inp?.底距7o || ''} onSave={txt=> setInp({...inp,底距7o: txt || undefined })}>m</SuffixInput>
                    </InputLine>
                    <Text>轿厢完全压缩缓冲器时，底坑空间计算结果值
                        (A7-H)= {floatInterception(inp?.['底距7o'] - inp?.['坑高差H'], 2)}</Text>
                    <InputLine label={`垂直距离A7-判定结论`}>
                        <SelectHookfork value={inp?.底距7r || ''}
                                        onChange={e => setInp({...inp, 底距7r: e.currentTarget.value || undefined})}/>
                    </InputLine>
                </LineColumn>
                {tail底坑}
            </InspectRecordLayout>
        );
});

export const PitspaceVw= ({children, orc, rep,label } : { orc: any, rep: any,label:any, children?: any}
) => {
    return <>
        <div css={{"@media print": {paddingBottom: '11.5rem', pageBreakInside: 'avoid'}}}>
            <Text variant="h5" css={{marginTop: '1rem',
            }}>{label}</Text>
            <div css={{textAlign: 'right'}}>单位：m</div>
        </div>
        <Table id='Pitspace' fixed={ ["5.4%","%", "9%", "5.2%","14.1%","10%","5.2%","5.2%"] }
               css={ {borderCollapse: 'collapse', "@media print": {marginTop: '-11.5rem'}} }  tight  miniw={800}>
            <TableHead>
                <TableRow>
                    <CCell>项目编号</CCell><CCell>检验内容与要求</CCell><CCell colSpan={2}>轿厢在下端站平层位置时，所测量的底坑空间值（A）</CCell>
                    <CCell>轿厢完全压缩缓冲器时，层门地坎与轿厢地坎的高差值（H）</CCell><CCell colSpan={2}>轿厢完全压缩缓冲器时，底坑空间计算结果值</CCell><CCell>结果判定</CCell>
                </TableRow>
            </TableHead>
            <TableBody>
                <RepLink ori rep={rep} tag={'Pitspace'}>
                    <TableRow>
                        <CCell rowSpan={3}>A1.2.2.12.1</CCell><CCell rowSpan={3}>底坑中有一个不小于 0.50m×0.60m × 1.00m 的空间(任一平面朝下均可)；</CCell>
                        <CCell>A1 =</CCell><CCell>{orc?.坑间1o??'／'}</CCell>
                        <CCell rowSpan={7} split>H={orc?.坑高差H??'／'}</CCell><CCell>(A1-H)=</CCell>
                        <CCell>{floatInterception(orc?.['坑间1o'] - orc?.['坑高差H'], 2, )??'／'}</CCell>
                        <CCell rowSpan={3}>{orc?.坑间r??'／'}</CCell>
                    </TableRow>
                    <TableRow>
                        <CCell>A2 =</CCell><CCell>{orc?.坑间2o??'／'}</CCell><CCell>A2 =</CCell>
                        <CCell>{floatInterception(orc?.['坑间2o'], 2, )??'／'}</CCell>
                    </TableRow>
                    <TableRow>
                        <CCell>A3 =</CCell><CCell>{orc?.坑间3o??'／'}</CCell><CCell>A3 =</CCell>
                        <CCell>{floatInterception(orc?.['坑间3o'], 2, )??'／'}</CCell>
                    </TableRow>
                    <TableRow>
                        <CCell rowSpan={3}>A1.2.2.12.1</CCell><CCell>底坑底面与轿厢最低部件的自由垂直距离不小于0.50m；</CCell>
                        <CCell colSpan={2}>垂直距离A4＝{orc?.底距4o??'／'}</CCell>
                        <CCell colSpan={2}>(A4-H)={floatInterception(orc?.['底距4o'] - orc?.['坑高差H'], 2, )??'／'}</CCell>
                        <CCell>{orc?.底距4r??'／'}</CCell>
                    </TableRow>
                    <TableRow>
                        <CCell>当垂直滑动门的部件、护脚板、夹紧装置钳块或者棘爪装置和相邻井道壁之间，轿厢最低部件和导轨之间的水平距离在 0.15m 之内时，此垂直距离允许减少到 0.10m；</CCell>
                        <CCell colSpan={2}>垂直距离A5＝{orc?.底距5o??'／'}</CCell>
                        <CCell colSpan={2}>(A5-H)={floatInterception(orc?.['底距5o'] - orc?.['坑高差H'], 2, )??'／'}</CCell>
                        <CCell>{orc?.底距5r??'／'}</CCell>
                    </TableRow>
                    <TableRow>
                        <CCell>当轿厢最低部件和导轨之间的水平距离大于 0.15m 但不大于 0.50时，此垂直距离可按线性关系增加至0.50m；</CCell>
                        <CCell colSpan={2}>垂直距离A6＝{orc?.底距6o??'／'}</CCell>
                        <CCell colSpan={2}>(A6-H)={floatInterception(orc?.['底距6o'] - orc?.['坑高差H'], 2, )??'／'}</CCell>
                        <CCell>{orc?.底距6r??'／'}</CCell>
                    </TableRow>
                    <TableRow>
                        <CCell>A1.2.2.12.1</CCell><CCell>底坑中固定的最高部件和轿厢最低部件(垂直滑动门的部件、护脚板、夹紧装置钳块或者棘爪装置除外)之间的自由垂直距离不小于0.30m。</CCell>
                        <CCell colSpan={2}>垂直距离A7＝{orc?.底距7o??'／'}</CCell>
                        <CCell colSpan={2}>(A7-H)={floatInterception(orc?.['底距7o'] - orc?.['坑高差H'], 2, )??'／'}</CCell>
                        <CCell>{orc?.底距7r??'／'}</CCell>
                    </TableRow>
                </RepLink>
            </TableBody>
        </Table>
        {tail底坑}
    </>;
};
